<?php
$imgDir = "./images";
$thumbDir = "./thumbnails";
$thOnPage = 5;

if(!$dir = @scandir($thumbDir)){
  die("error\nBd serwera. Galeria nie jest dostpna.");
}
array_shift($dir);
array_shift($dir);

$count = count($dir);
$pages = ceil($count / $thOnPage);

if(isSet($_GET['iid'])){
  $iId = $_GET['iid'];
  if(!is_numeric($iId) || $iId < 0 || $iId >= $count){
    $iId = 0;
  }
  die(getImgDiv());
}
else if(isSet($_GET['pid'])){
  $pId = $_GET['pid'];
  if(!is_numeric($pId) || $pId < 0 || $pId > $pages){
    $pId = 0;
  }
  die(getThDiv());
}
else{
  $iId = 0;
  $pId = 0;
}
?>